<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div v-show="!isLogin">
        <a href="javascript:void(0)">注册</a>
        <a href="javascript:void(0)" @click="login()">登录</a>
    </div>
    <div v-show="isLogin">
        <a href="javascript:void(0)" @click="logout()">登出</a>
        <input type="text" v-model="newName">
        <a href="javascript:void(0)" @click="add()">添加</a>
    </div>
    <ul v-for="name in arr">
        <li>{{name}}</li>
    </ul>
</div>
<!--引入vue-->
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            isLogin: false,
            arr: ["悟空", "八戒"],
            newName: ""
        },
        methods: {
            login: function () {
                v.isLogin = true;
            },
            logout: function () {
                v.isLogin = false;

            },
            add: function () {
                //把用户输入的内容 添加到数组中
                v.arr.push(v.newName);
            }

        }
    })
</script>
</body>
</html>